﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace OrbitOne.Elmah.Presenter
{
    public class ErrorDetail : ErrorDetailBase
    {
        #region Controls
        protected Repeater ServerVariables;
        protected Repeater FormVariables;
        protected Repeater Cookies;
        #endregion

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            ServerVariables.DataSource = GetHashtableFromNameValueCollection(ElmahError.ServerVariables);
            FormVariables.DataSource = GetHashtableFromNameValueCollection(ElmahError.Form);
            Cookies.DataSource = GetHashtableFromNameValueCollection(ElmahError.Cookies);
            ServerVariables.DataBind();
            FormVariables.DataBind();
            Cookies.DataBind();
        }

        private Hashtable GetHashtableFromNameValueCollection(NameValueCollection collection)
        {
             var result = new Hashtable();
            foreach(var str in collection.AllKeys)
            {
                result.Add(str, collection[str]);
            }
            return result;
        }
    }
}
